<template>
    <div>
            <div id="formdemo01">
       
     <el-form  :model="formInline" class="demo-form-inline">
          <el-row :gutter="12">
              <el-col :span="5">
         <el-form-item label="姓名:">
    <el-input class="input1" v-model="formInline.name"></el-input>
  </el-form-item>
  </el-col>
   <el-col :span="5">
  <el-form-item label="身份证号:">
    <el-input v-model="formInline.card" ></el-input>
  </el-form-item>
  </el-col>
   <el-col :span="5">
  <el-form-item label="年龄:">
    <el-input v-model="formInline.age" ></el-input>
  </el-form-item>
   
  </el-col>
  <el-col :span="5">
  <el-form-item label="科室:">
    <el-input v-model="formInline.departmentname" ></el-input>
  </el-form-item>
  </el-col>
  
  
     

  
   <el-col  :span="5">
  <el-form-item label="医生:">
    <el-input v-model="formInline.doctorname" ></el-input>
  </el-form-item>
   </el-col>
   <el-col :span="5">
   <el-form-item label="电话:">
    <el-input v-model="formInline.telephone" ></el-input>
  </el-form-item>
   </el-col>
   <el-col :span="5">
   <el-form-item label="挂号费:">
    <el-input v-model="formInline.cost" ></el-input>
  </el-form-item>
   </el-col>
   <el-col :span="5">
   <el-form-item label="审批人">
    <el-input v-model="formInline.user" placeholder="审批人"></el-input>
  </el-form-item>
   </el-col>
   <el-row  :gutter="20">
         <el-col :span="12" :offset="8">
            
        <el-button type="primary" icon="el-icon-check" @click="dialogTableVisible  = true">选择患者</el-button> 
             </el-col>
            </el-row>

  </el-row>

    </el-form>
 </div>  
        <div>
<el-dialog  width="1200px" title="选择病人" :visible.sync="dialogTableVisible ">
     
     <div class="shousuo">
      <el-input  v-model="sou" placeholder="请输入搜索内容" style="width:240px;margin-bottom: 40px;"></el-input>
      <el-button style="margin-left: 20px;" icon="el-icon-search" circle></el-button>
    </div>


   <el-table
    :data="tableData.slice((currentPage - 1) * pagesize, currentPage * pagesize)"
    border
    >
  

    <el-table-column
      prop="id"
      label="单据号"
      width="100">
    </el-table-column>
    <el-table-column
      prop="name"
      label="姓名"
      width="100">
    </el-table-column>
    <el-table-column
      prop="telephone"
       width="180"
      label="电话">
    </el-table-column>
    <el-table-column
     width="180"
      prop="card"
      label="身份证号">
    </el-table-column>
    <el-table-column
      prop="age"
      label="年龄">
    </el-table-column>
    <el-table-column
     width="130"
      prop="departmentname"
      label="科室">
    </el-table-column>
    <el-table-column
      prop="doctorname"
      label="医生">
    </el-table-column>
    <el-table-column
      prop="type"
      label="挂号类别">
    </el-table-column>
    <el-table-column
      prop="date"
      label="挂号时间">
    </el-table-column>
    <el-table-column
      prop="cost"
      label="挂号费">
    </el-table-column>
    
     <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="hzhandleClick(scope.row)" type="primary" size="small">选择患者</el-button>
        
      </template>
    </el-table-column>
  </el-table>

 
  <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[2,4,6,10]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.length">
    </el-pagination>

</el-dialog>

 </div>
 <div>
    <el-dialog title="填写症状" :visible.sync="bingzhuangDialogVisible">
  <el-form :model="formbz">
    <el-form-item label="填写用户病状">
    <el-input :rows="4" :autosize="{ minRows: 2, maxRows: 4}" type="textarea" v-model="formbz.bingzhuang"></el-input>
  </el-form-item>
    <el-form-item>
    <el-button type="primary" @click="tijiaoby">提交</el-button>
    <el-button>取消</el-button>
  </el-form-item>
  </el-form>  
  </el-dialog>   
</div>       
       
  <div class="xiangmujctable" v-if="xmisshow">
   <el-table
    :data="xiangmu.slice((currentPage - 1) * pagesize, currentPage * pagesize)"
    border
    style="width: 1000px"
    :header-cell-style="{background:'gainsboro', color:'#000'}"
    >

   <el-table-column
      prop="name"
      label="项目名称"
      >
    </el-table-column>
    <el-table-column
      prop="cishu"
      label="数量"
     >
    </el-table-column>
    <el-table-column
      prop="cost"
      
      label="单价">
    </el-table-column>
    <el-table-column
    
      prop="total"
      label="小计">
    </el-table-column>
     <el-table-column
      prop="sfjiancha"
      label="状态">
    </el-table-column>
      <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template >
        <el-button @click="bingzhuangDialogVisible=true" type="primary" size="small">编辑</el-button>
        
      </template>
    </el-table-column>
  </el-table>
  <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[2,4,6,10]"
      :page-size="pagesize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="xiangmu.length">
    </el-pagination>
 </div>
    <div>
       <el-dialog  :visible.sync="chenggongDialogVisible">
          <el-result icon="success" title="成功提示" subTitle="请根据提示进行操作">
      <template slot="extra">
        <el-button type="primary" size="medium">返回</el-button>
      </template>
    </el-result>
  </el-dialog>   
     
    </div>
    </div>
</template>
<script>

import { ghlist,chaxunid} from "../../api/Department";
import { getgoumai,getjiancha,yijiancha} from "../../api/Listofnoninpatientitems";
import { addyz} from "../../api/order";
export default {
    data(){
        return{
          
            bingzhuangDialogVisible:false,
            chenggongDialogVisible:false,
          xmisshow:false,
          orderType:'检查结果',
          sfjc:'已检查',
            sou:'',
            pagesize:2,
            currentPage:1,
            dialogTableVisible:false,
            formbz:{
              bingzhuang:'',
            },
         formInline: {
        name:"",
        card:"",
        age:"",
        departmentname:"",
        doctorname:"",
        telephone:"",
         cost: "",
        region: "",
      }, 
          tableData: [
        {
        id:'',
        name: "",
        age:'',
        telephone: "",
        card: "",        
        type:'',
        doctorname:'',
        departmentname:'',
        date:'',
        cost:'',
        }
        
      ],
       xiangmu:[{
        name:'',
        cost:'',
        cishu:'',
        total:'',
        sfjiancha:'',
      }],
        }
    },
     mounted(){
      this.chaxunguahao();
     

    },
   
    methods:{
         handleSizeChange(pagesize) {
       this.pagesize=pagesize;
      },
      handleCurrentChange(currentPage) {
        this.currentPage=currentPage;
      },
      bjhandleClick(row){
        this.bingzhuangDialogVisible=true
      },
      tijiaoby(){
        addyz({patientId:this.userid,orderType:this.orderType,jieguo:this.formbz.bingzhuang}).then(res=>{
           if(res.success){
                this.$message({
          message: '检查成功',
          type: 'success'
        });
          this.bingzhuangDialogVisible=false;
           }
        }).then(()=>{
          console.log(this.sfjc)
          console.log(this.userid)
          yijiancha({sfjiancha:this.sfjc,patientid:this.userid}).then(res=>{
            
           if(res.success){
              getjiancha({patientId:this.userid}).then(res=>{
            this.xiangmu=res.result
        })  
           }
          })
         
        })
      },
      hzhandleClick(row){
          this.dialogTableVisible=false;
          this.xmisshow=true
           this.formInline=row
            this.formInline.name=row.name
            chaxunid({name:this.formInline.name}).then(res=>{ 
               this.userid=res.result[0].id
                getjiancha({patientId:this.userid}).then(res=>{
            this.xiangmu=res.result
        })  
             
           })
      },
        chaxunguahao(){
          ghlist().then(res=>{
           
            this.tableData=res.result
          })
       },
    }
}
</script>
<style  scoped>
#formdemo01{
     margin-top: 30px;
  margin-left: 150px;
}
.xiangmujctable{
 
  margin-top: 40px;
  margin-left:110px;
  width: 1600px;
  height: 300px;

  padding-right: 400px;
}


</style>
